<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>公告管理</title>
    <link rel="stylesheet" href="<?=adminassets?>assets/pear/component/pear/css/pear.css" />
    <link rel="stylesheet" href="<?=adminassets?>assets/css/Notice.css" />
    
</head>
<body class="pear-container">
    <?php if ($my == "list") : ?>
        <div class="layui-card">
            <div class="layui-card-body">
                <table id="news" lay-filter="news"></table>
            </div>
        </div>

        <script type="text/html" id="toolbar">
            <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                新增公告
            </button>
        </script>

        <script type="text/html" id="status">
            <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="status" {{# if(d.status==1){ }} checked {{# } }}>
        </script>

        <script type="text/html" id="options">
            <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
            <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
        </script>
    <?php endif; ?>

    <?php if ($my == "add" || $my == "edit") : ?>
        <form class="layui-form" action="">
            <div class="mainBox">
                <div class="main-container">
                    <?php if ($my == "edit") : ?>
                        <input type="hidden" name="id" value="<?=$id?>" />
                    <?php endif; ?>
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">公告标题</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="title" placeholder="请输入公告标题" 
                                value="<?=$my == 'edit' ? $row['title'] : ''?>" required />
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">公告内容</label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea" id="add_news" name="datatxt" placeholder="请输入公告内容" required><?=$my == 'edit' ? $row['datatxt'] : ''?></textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-block">
                            <input type="number" class="layui-input" name="sort" placeholder="请输入排序号" 
                                value="<?=$my == 'edit' ? $row['sort'] : '50'?>" required />
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">文字颜色</label>
                        <div class="layui-input-block color-picker">
                            <input type="text" class="layui-input" id="colorInput" name="color" placeholder="请选择文字颜色" 
                                value="<?=$my == 'edit' ? ($row['color'] ? $row['color'] : '#000000') : '#000000'?>" maxlength="7"/>
                            <span class="color-picker-icon">
                                <i id="colorPickerIcon"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="bottom">
                <div class="button-container">
                    <button type="submit" class="pear-btn pear-btn-primary" lay-submit 
                        lay-filter="<?=$my == 'edit' ? 'editSave' : 'addSave'?>">
                        <i class="layui-icon layui-icon-ok"></i> 提交
                    </button>
                    <button type="reset" class="pear-btn pear-btn-danger">
                        <i class="layui-icon layui-icon-refresh"></i> 重置
                    </button>
                </div>
            </div>
        </form>
    <?php endif; ?>

    <script src="<?=adminassets?>assets/pear/component/layui/layui.js"></script>
    <script src="<?=adminassets?>assets/pear/component/pear/pear.js"></script>
    <script src="<?=adminassets?>assets/js/core_js/Notice.js?v=<?=time()?>"></script>
</body>
</html>